<template>
  <section class="login_bg">
    <div class="login_title">
      <h1>欢迎畅享你的登录</h1>
    </div>
    <div class="loginPane">
      <img src="https://iconfont.alicdn.com/t/32895ba0-79e9-4bee-a214-061d1247d7e4.png" class="loginImg">
      <div class="loginInputBox">
        <el-input placeholder="用户名/邮箱" v-model="loginForm.name" class="mb-20">
          <i slot="prefix" class="el-input__icon el-icon-user"></i>
        </el-input>
        <el-input placeholder="用户密码" v-model="loginForm.pwd" class="mb-20" show-password>
          <i slot="prefix" class="el-input__icon el-icon-unlock"></i>
        </el-input>
        <el-checkbox label="记住密码" v-model="loginForm.recode" name="type" class="mt-20"></el-checkbox>
        <div class="clear"></div>
        <el-button type="primary" @click="loginHandler" class="loginBtn mt-20">立即登录
        </el-button>
      </div>
    </div>
  </section>
</template>
<script>
// import { login } from 'apis/user'
export default {
  name: 'login',
  data() {
    return {
      loginForm: {
        name: '',
        pwd: '',
        recode: '',
      },
    }
  },
  methods: {
    loginHandler() {
      if (this.submitValidate()) {
        window.sessionStorage.setItem('token', 'BDCUYUYCBUVBUHBVUGJHBVEYUVV')
        this.$router.replace('/home')
      }
      // let key = {
      //   name: 'superadmin',
      //   password: '111111',
      // }
      // login(key).then((res) => {
      //   debugger
      //   if (res.data.code === 200) {
      //     let data = res.data
      //     alert('登录成功~')
      //     let info = {
      //       flag: true,
      //       userid: data.account.id,
      //       token: data.token,
      //       cookie: data.cookie,
      //     }
      //     sessionStorage.setItem('state', JSON.stringify(info))
      //     // this.$store.commit("setAccessToken", info);
      //     // this.$router.replace("/home");
      //   } else {
      //     alert(res.data.msg)
      //   }
      // })
    },
    submitValidate () {
      if (!this.loginForm.name) {
        this.$notify.success({
          title: 'Info',
          message: '这是一条没有关闭按钮的消息',
          showClose: false,
        })
        return false
      }
      if (!this.loginForm.pwd) {
        this.$notify.success({
          title: 'Info',
          message: '这是一条没有关闭按钮的消息',
          showClose: false,
        })
        return false
      }
      return true
    },
  },
}
</script>
<style lang="scss" scoped>
@import '~styles/default/login_view.scss';
</style>